home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 401-425 / disk_421 / ezasm / window.asm < prev    next >
Assembly Source File  |  1992-05-06  |  3KB  |  191 lines

  1.  
  2.  
  3.  
  4. *    Opens a window, gets the window's fontdata into our CHIP area
  5. *        and blits part of it into the window.
  6.  
  7. *    ( uses "ENDS" for data at bottom )
  8. *    ( text might be trashed under 2.0 )
  9.  
  10. *    click left mouse button to exit
  11.  
  12.  
  13.         include    "intuition/intuition.i"
  14.         include    "exec/types.i"
  15.         include    "graphics/gfx.i"
  16.         include    "graphics/rastport.i"
  17.  
  18.  
  19.  
  20. CLEAR_CHIP    equ    $10002
  21.  
  22.  
  23.         CSEG
  24.  
  25.  
  26.  
  27. Wind        equ    -4
  28. _IntuitionBase    equ    -8
  29. FontData    equ    -12
  30. Planes        equ    -16
  31. _GfxBase    equ    -20
  32.  
  33.  
  34.         XREF    _LVOAllocMem
  35.         XREF    _LVOOpenLibrary
  36.         XREF    _LVOOpenWindow
  37.         XREF    _LVOCloseWindow
  38.         XREF    _LVOCloseLibrary
  39.         XREF    _LVOFreeMem
  40.  
  41.         link    a5,#-24
  42.  
  43.         movea.l    $4,a6
  44.         move.l    #2048,d0
  45.         move.l    #CLEAR_CHIP,d1
  46.         jsr    _LVOAllocMem(a6)
  47.         move.l    d0,FontData(a5)
  48.         beq    Quit
  49.  
  50.         movea.l    #intuiname,a1
  51.         moveq    #0,d0
  52.         jsr    _LVOOpenLibrary(a6)
  53.         move.l    d0,_IntuitionBase(a5)
  54.         beq    Quit
  55.  
  56.         movea.l    #graphname,a1
  57.         moveq    #0,d0
  58.         jsr    _LVOOpenLibrary(a6)
  59.         move.l    d0,_GfxBase(a5)
  60.         beq    Quit
  61.  
  62.         movea.l    _IntuitionBase(a5),a6
  63.         movea.l    #newwin,a0
  64.         jsr    _LVOOpenWindow(a6)
  65.         move.l    d0,Wind(a5)
  66.         beq    Quit
  67.  
  68.  
  69.  
  70. *    a handy debugging aid!
  71.  
  72. *    ( just remove the '*', change the color, and be sure a label's
  73. *    before the next one )
  74.  
  75. *        d6 = 1000
  76. *1$        d7 = 10000
  77. *2$        ($dff180) = $0f0 w    ;GREEN
  78. *        dbf    d7,2$
  79. *        dbf    d6,1$
  80.  
  81.  
  82.  
  83.  
  84.  
  85. *   load fontdata into our chip area
  86.  
  87.         movea.l    Wind(a5),a0
  88.         movea.l    wd_RPort(a0),a1
  89.         movea.l    rp_Font(a1),a2
  90.         movea.l    tf_CharData(a2),a3
  91.  
  92.         move.l    #383,d1
  93.         movea.l    FontData(a5),a4
  94. FontLoop    move.l    (a3)+,(a4)+
  95.         dbf    d1,FontLoop
  96.  
  97.  
  98. *   get addr of windows 1st bitplane
  99.  
  100.         movea.l    rp_BitMap(a1),a2
  101.         move.l    bm_Planes(a2),Planes(a5)
  102.  
  103.  
  104. *   blit out first portion of fontdata
  105.  
  106.  
  107.         lea    14675968,a6
  108.  
  109.         move.w    #$03aa,$40(a6)    ;BLTCON0  USE: C D  D=C
  110.         move.w    #$007a,$60(a6)    ;BLTCMOD
  111.         move.w    #$000a,$66(a6)    ;BLTDMOD
  112.  
  113.         move.l    Planes(a5),d1
  114.         addi.l    #1605,d1
  115.         move.l    d1,$54(a6)
  116.  
  117.         move.l    FontData(a5),$48(a6)
  118.  
  119.         clr.w    $74(a6)    ;BLTADAT
  120.         clr.w    $72(a6)    ;BLTBDAT
  121.  
  122.         move.w    #$8240,$96(a6)    ;DMACON   SET DMAEN BLTEN
  123.  
  124.         move.w    #547,$58(a6)    ;BLTSIZE
  125.  
  126.  
  127. BlitWait    btst.b    #6,$dff002
  128.         bne    BlitWait    ;DMACONR  BBUSY?
  129.  
  130. QuitLoop    btst.b    #6,$bfe001
  131.         bne    QuitLoop    ;wait for LMB down
  132.  
  133.  
  134. Quit
  135.         tst.l    Wind(a5)
  136.         beq    .laaa
  137.         movea.l    _IntuitionBase(a5),a6
  138.         movea.l    Wind(a5),a0
  139.         jsr    _LVOCloseWindow(a6)
  140. .laaa
  141.  
  142.         tst.l    _IntuitionBase(a5)
  143.         beq    .laab
  144.         movea.l    $4,a6
  145.         movea.l    _IntuitionBase(a5),a1
  146.         jsr    _LVOCloseLibrary(a6)
  147. .laab
  148.  
  149.         tst.l    _GfxBase(a5)
  150.         beq    .laac
  151.         movea.l    $4,a6
  152.         movea.l    _GfxBase(a5),a1
  153.         jsr    _LVOCloseLibrary(a6)
  154. .laac
  155.  
  156.         tst.l    FontData(a5)
  157.         beq    .laad
  158.         movea.l    $4,a6
  159.         movea.l    FontData(a5),a1
  160.         move.l    #2048,d0
  161.         jsr    _LVOFreeMem(a6)
  162. .laad
  163.  
  164.  
  165.         unlk    a5
  166.         moveq    #0,d0
  167.         rts
  168.  
  169.  
  170.         DSEG
  171.  
  172.  
  173.  
  174. newwin        ds.w    0
  175.  
  176.         dc.w    0,0,640,200
  177.         dc.b    -1,-1
  178.         dc.l    0
  179.         dc.l    WINDOWDRAG|WINDOWSIZING|SIZEBRIGHT|ACTIVATE|SMART_REFRESH
  180.         dc.l    0,0,0,0,0
  181.         dc.w    100,100,640,400
  182.         dc.w    WBENCHSCREEN
  183.  
  184.  
  185. intuiname    dc.b    "intuition.library",0
  186. graphname    dc.b    "graphics.library",0
  187.  
  188.  
  189.  
  190.         END
  191.